package com.ruoyi.security.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.omp.api.RemoteTrendService;
import com.ruoyi.security.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "大屏-智慧消防")
@RestController
@RequestMapping("/dp_firefighting")
public class DPFireFightingController extends BaseController {

    @Autowired
    private RemoteTrendService remoteTrendService;

    // dp_security_summary

    @ApiOperation(value="BP-智慧消防-消防总揽", notes="智慧消防-消防总揽")
    @GetMapping(value = "/dp_fire_summary")
    public AjaxResult dp_security_summary(@RequestParam(value = "parkNum",required = false) String parkNum) {
        String trendType = "dp_fire_summary";
        R remote = remoteTrendService.getTrendDataByType(trendType,-1);
        Map<String,String> result = (Map<String,String>)remote.getData();

        return AjaxResult.success(result);
    }

    @ApiOperation(value="BP-智慧消防-设备在线", notes="智慧消防-设备在线")
    @GetMapping(value = "/dp_fire_device")
    public AjaxResult dp_fire_device(@RequestParam(value = "parkNum",required = false) String parkNum) {
        String trendType = "dp_fire_device";
        R remote = remoteTrendService.getTrendDataByType(trendType,-1);
        Map<String,String> result = (Map<String,String>)remote.getData();

        return AjaxResult.success(result);
    }

    @ApiOperation(value="BP-智慧消防-设备类型", notes="智慧消防-设备类型")
    @GetMapping(value = "/dp_fire_device_type")
    public AjaxResult dp_fire_device_type(@RequestParam(value = "parkNum",required = false) String parkNum) {
        String trendType = "dp_fire_device_type";
        R remote = remoteTrendService.getTrendDataByType(trendType,-1);
        Map<String,String> result = (Map<String,String>)remote.getData();

        return AjaxResult.success(result);
    }

    //
    @ApiOperation(value="BP-智慧消防-消防值班", notes="智慧消防-消防值班")
    @GetMapping(value = "/dp_fire_work")
    public AjaxResult dp_fire_work() {
        String sql = "select elevator_code,elevator_name,location,state from omp_af_elevator group by state,elevator_code";
        R remote = remoteTrendService.execSql(sql);
        return AjaxResult.success(remote.getData());
    }

    @ApiOperation(value="BP-智慧消防-消防报警", notes="智慧消防-消防报警")
    @GetMapping(value = "/dp_fire_alarm")
    public AjaxResult dp_fire_alarm() {
        //设备编号，设备类型，园区，栋号，楼层，详细位置，描述，时间，状态。
        String sql = "select id,device_num,device_type,park_num,build_num,build_floor,installtion,report_time,desc1,state from dp_fire_alarm";
        R remote = remoteTrendService.execSql(sql);
        return AjaxResult.success(remote.getData());
    }

    @ApiOperation(value="BP-智慧消防-事件分析", notes="智慧消防-事件分析")
    @GetMapping(value = "/dp_fire_analysis")
    public AjaxResult dp_fire_analysis(){
        String trendType = "dp_fire_analysis";
        R remote = remoteTrendService.getTrendDataByType(trendType,-1);
        Map<String,String> result = (Map<String,String>)remote.getData();

        return AjaxResult.success(result);
    }

    @ApiOperation(value="BP-智慧消防-隐患排除", notes="智慧消防-隐患排除")
    @GetMapping(value = "/dp_fire_risks_lifted")
    public AjaxResult dp_fire_risks_lifted(){
        //位置，隐患类型，排查时间，状态
        String trendType = "dp_fire_risks_lifted";
        R remote = remoteTrendService.getTrendDataByType(trendType,-1);
        Map<String,String> result = (Map<String,String>)remote.getData();

        return AjaxResult.success(result);
    }

    @ApiOperation(value="BP-智慧消防-隐患列表", notes="智慧消防-隐患列表")
    @GetMapping(value = "/dp_fire_risks")
    public AjaxResult dp_fire_risks(){
        //位置，隐患类型，排查时间，状态
        String sql = "select elevator_code,elevator_name,location,state from omp_af_elevator group by state,elevator_code";
        R remote = remoteTrendService.execSql(sql);
        return AjaxResult.success(remote.getData());
    }

}
